package com.hyh.shiyanshiguanli.mapper;

import com.github.pagehelper.Page;
import com.hyh.shiyanshiguanli.domain.dto.ClassifyDTO;
import com.hyh.shiyanshiguanli.domain.dto.ClassifyUpdateDTO;
import com.hyh.shiyanshiguanli.domain.entity.Classify;
import com.hyh.shiyanshiguanli.domain.entity.LibInformation;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author hyh
 * @version 1.0
 */
@Mapper
public interface ClassifyMapper {

    Page<Classify> page(ClassifyDTO classifyDTO);
    
    @Select("select * from lib_classify where id = #{id}")
    Classify selectById(@Param("id") Integer id);

    void updateById(Classify classify);

    @Insert("insert into lib_classify (name, description, lib_manager_id, lib_manager) " +
            "values (#{name},#{description},#{libManagerId},#{libManager})")
    void add(Classify classify);

    @Delete("delete from lib_classify where id = #{id}")
    void deleteById(Integer id);

    @Select("select * from lib_classify")
    List<Classify> selectClassify();

    /**
     * 增加分类下的number
     * @param libClassifyId
     */
    @Update("update lib_classify set number = number  + 1 where id = #{libClassifyId}")
    void addNumberByLibClassifyId(@Param("libClassifyId") Integer libClassifyId);
}
